package com.aaa.service.mht.impl;

import com.aaa.dao.mht.ViewTestResultMhtDao;
import com.aaa.entity.PageSortEntity;

import com.aaa.entity.mht.TestResultMht;
import com.aaa.entity.mht.ViewTestResultMht;
import com.aaa.service.mht.ViewTestResultMhtService;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * (ViewTestResultMht)表服务实现类
 *
 * @author makejava
 * @since 2022-09-05 19:41:05
 */
@Service("viewTestResultMhtService")
public class ViewTestResultMhtServiceImpl implements ViewTestResultMhtService {
    @Resource
    private ViewTestResultMhtDao viewTestResultMhtDao;


    @Override
    public Page queryAll(PageSortEntity pageSortEntity, ViewTestResultMht viewTestResultMht) {
        //分页
        PageHelper.startPage(pageSortEntity.getPage(), pageSortEntity.getLimit(), pageSortEntity.getOrderString());
        List<ViewTestResultMht> viewTestResultMhts = viewTestResultMhtDao.queryAll(viewTestResultMht);
        Page pageResult = (Page) viewTestResultMhts;
        return pageResult;
    }

    @Override
    public List<ViewTestResultMht> queryAllById(ViewTestResultMht viewTestResultMht) {
        List<ViewTestResultMht> viewTestResultMhts = viewTestResultMhtDao.queryAllById(viewTestResultMht);
        return viewTestResultMhts;
    }

    @Override
    public Map queryResultToReport() {
        ViewTestResultMht viewTestResultMht = new ViewTestResultMht();
        List<ViewTestResultMht> viewTestResultMhts = viewTestResultMhtDao.queryAll(viewTestResultMht);
        Map viewTestResultMht1 = new HashMap();
        Long studyanxiety = 0L;
        Long peopleanxiety = 0L;
        Long feelalone = 0L;
        Long feelremorse = 0L;
        Long feelallergic = 0L;
        Long body = 0L;
        Long feelterror = 0L;
        Long easyimpulse = 0L;
        int x = 0;
        for (ViewTestResultMht testResultMht : viewTestResultMhts) {
            studyanxiety += testResultMht.getStudyanxiety();
            peopleanxiety += testResultMht.getPeopleanxiety();
            feelalone += testResultMht.getFeelalone();
            feelremorse += testResultMht.getFeelremorse();
            feelallergic += testResultMht.getStudyanxiety();
            body += testResultMht.getBody();
            feelterror += testResultMht.getFeelterror();
            easyimpulse += testResultMht.getEasyimpulse();
            x++;
        }
        viewTestResultMht1.put("studyanxiety", studyanxiety);
        viewTestResultMht1.put("peopleanxiety", peopleanxiety);
        viewTestResultMht1.put("feelalone", feelalone);
        viewTestResultMht1.put("feelremorse", feelremorse);
        viewTestResultMht1.put("feelallergic", feelallergic);
        viewTestResultMht1.put("body", body);
        viewTestResultMht1.put("feelterror", feelterror);
        viewTestResultMht1.put("easyimpulse", easyimpulse);
        viewTestResultMht1.put("sumpeople", x);
        return viewTestResultMht1;
    }

    @Override
    public Map queryResultToReportbyid() {
        ViewTestResultMht viewTestResultMht = new ViewTestResultMht();
        List<ViewTestResultMht> viewTestResultMhts = viewTestResultMhtDao.queryAllById(viewTestResultMht);
        Map viewTestResultMht1 = new HashMap();
        Long studyanxiety = 0L;
        Long peopleanxiety = 0L;
        Long feelalone = 0L;
        Long feelremorse = 0L;
        Long feelallergic = 0L;
        Long body = 0L;
        Long feelterror = 0L;
        Long easyimpulse = 0L;
        int x = 0;
        for (ViewTestResultMht testResultMht : viewTestResultMhts) {
            studyanxiety += testResultMht.getStudyanxiety();
            peopleanxiety += testResultMht.getPeopleanxiety();
            feelalone += testResultMht.getFeelalone();
            feelremorse += testResultMht.getFeelremorse();
            feelallergic += testResultMht.getStudyanxiety();
            body += testResultMht.getBody();
            feelterror += testResultMht.getFeelterror();
            easyimpulse += testResultMht.getEasyimpulse();
            x++;
        }
        viewTestResultMht1.put("studyanxiety", studyanxiety);
        viewTestResultMht1.put("peopleanxiety", peopleanxiety);
        viewTestResultMht1.put("feelalone", feelalone);
        viewTestResultMht1.put("feelremorse", feelremorse);
        viewTestResultMht1.put("feelallergic", feelallergic);
        viewTestResultMht1.put("body", body);
        viewTestResultMht1.put("feelterror", feelterror);
        viewTestResultMht1.put("easyimpulse", easyimpulse);
        viewTestResultMht1.put("sumpeople", x);
        return viewTestResultMht1;
    }

    @Override
    public Page queryTestResultById(PageSortEntity pageSortEntity, TestResultMht testResultMht) {
        PageHelper.startPage(pageSortEntity.getPage(), pageSortEntity.getLimit(), pageSortEntity.getOrderString());
        List<TestResultMht> testResultMhts = viewTestResultMhtDao.queryTestResultById(testResultMht);
        Page pageResult = (Page) testResultMhts;
        return pageResult;
    }


}
